{template "nheader.html"}
<script type="text/javascript">
$(function() {

	//每隔5秒保存表单数据
	{if !$data.id && !$did}
	setInterval("dr_save_add_data()", 5000);
	{/if}
	// 加载草稿
	$("#dr_cgbox").mouseover(function(){
		$(".dr_cgbox").show();
	}).mouseout(function(){
		$(".dr_cgbox").hide();
	});
	// 删除草稿数据
	$(".dr_cgbox_delete").click(function(){
		var did = $(this).attr("did");
		var num = parseInt($("#dr_cg_nums").html());
		$.ajax({
			type: "POST",
			dataType:"json",
			url: memberpath+'index.php?s=member&c=api&m=ajax_delete_draft&sid={SITE_ID}&dir={MOD_DIR}&did='+did,
			success: function(data) {
				if (data == did) {
					$("#dr_cgbox_"+did).remove();
					$("#dr_cg_nums").html(num - 1);
				} else {
					dr_tips(data);
				}
			},
			error: function(HttpRequest, ajaxOptions, thrownError) { }
		});
	});
	$(".dr_cgbox_select").click(function(){
		var did = $(this).attr("did");
		window.location.href = '{$draft_url}&did='+did;
	});
	// 自动保存草稿
	{if $did}
	setInterval("dr_save_draft_data()", 5000);
	{/if}
});
function show_category_field(catid) {
	{if $category_field_url}
		window.location.href = '{$category_field_url}&catid='+catid;
		{/if}
		}
		function dr_sync(id, _this) {
			var tid = $("#dr_"+id).val();
			if (tid == 1) {
				$("#dr_"+id).val("0");
				$(_this).attr("src", "{THEME_PATH}oauth/"+id+".gif");
			} else {
				$("#dr_"+id).val("1");
				$(_this).attr("src", "{THEME_PATH}oauth/"+id+"_on.gif");
			}
		}
		function dr_select_category() {
			$("#dr_select_category_html > span").hide();
			$("#dr_select_category").show();
		}
// 动态保存草稿数据
		function dr_save_draft_data() {
			var catid = $('#dr_catid').val();
			$.ajax({
				type: "POST",
				dataType:"json",
				url: memberpath+'index.php?s=member&c=api&m=ajax_save_draft&sid={SITE_ID}&dir={MOD_DIR}&did={$did}&catid='+catid,
				data: $("#myform").serialize(),
				success: function(data) { },
				error: function(HttpRequest, ajaxOptions, thrownError) { }
			});
		}
// 动态保存表单数据
		function dr_save_add_data() {
			$.ajax({
				type: "POST",
				dataType:"json",
				url: memberpath+'index.php?s=member&c=api&m=ajax_save_add&dir={MOD_DIR}',
				data: $("#myform").serialize(),
				success: function(data) { },
				error: function(HttpRequest, ajaxOptions, thrownError) { }
			});
		}
</script>

<form action="" method="post" id="myform" class="form-horizontal" novalidate="novalidate">
	<input name="action" id="dr_action" type="hidden" value="" />
	<input name="dr_id" id="dr_id" type="hidden" value="{$data.id}" />
	<input name="dr_module" id="dr_module" type="hidden" value="{MOD_DIR}" />
	<div class="form-body">
		<div class="portlet light bordered">
			<div class="portlet-title  mytitle">
				<div class="caption"><span class="caption-subject font-green">{fc_lang('基本内容')}</span></div>
				{if $draft_list}
				<div class="actions">
					<div class="btn-group">
						<a class="btn btn-sm green dropdown-toggle" href="javascript:;" data-toggle="dropdown" aria-expanded="false" data-hover="dropdown"> 草稿（<span id="dr_cg_nums">{count($draft_list)}</span>）
							<i class="fa fa-file-o"></i>
						</a>
						<ul class="dropdown-menu pull-right">
							{loop $draft_list $t}
							<li id="dr_cgbox_{$t.id}">
								<a href="javascript:;" class="dr_cgbox_select" did="{$t.id}">{dr_date($t.inputtime)}</a>
							</li>
							{/loop}
						</ul>
					</div>
				</div>
				{/if}
			</div>
			<div class="portlet-body">
				{if !$isedit}
				<div class="form-group">
					<label class="col-md-2 control-label"><font color="red">*</font>{fc_lang('栏目分类')}：</label>
					<div class="col-md-10 ">
						<label>{$select}</label>
					</div>
				</div>
				{else}
				<div class="form-group">
					<label class="col-md-2 control-label"><font color="red">*</font>{fc_lang('栏目分类')}：</label>
					<div class="col-md-10">
						<div class="form-control-static">{dr_catpos($catid, '&nbsp;&nbsp;>&nbsp;&nbsp;', FALSE)}</div>
					</div>
				</div>
				{/if}
				{$myfield}
				{if $is_post_code}
				<div class="form-group" id="dr_row_code">
					<label class="control-label col-md-2"><span class="required" aria-required="true"> * </span> 验证码：</label>
					<div class="col-md-5">
						<label>
							<div class="form-recaptcha">
								<div class="input-group">
									<input type="text" id="dr_code" class="form-control" name="code">
									<div class="input-group-btn fc-code">
										{dr_code(120, 35)}
									</div>
								</div>
							</div>
						</label>
					</div>
				</div>
				{/if}
			</div>


		</div>
	</div>
	<div class="form-actions">
		<div class="row">
			<div class="col-md-offset-2 col-md-3">
				<button  type="button"  onclick="$('#dr_action').val('');dr_cmf_module_submit('{dr_now_url()}', 'myform')" class="mysubmit btn green"><i class="fa fa-save"></i> 保存</button>
				<button  type="button"  onclick="$('#dr_action').val('draft');dr_cmf_module_submit('{dr_now_url()}', 'myform')" class="mysubmit btn blue"> <i class="fa fa-file-o"></i> 草稿</button>
			</div>
		</div>
	</div>
</form>

{template "nfooter.html"}